#pragma once
#include "stdafx.h"
#include "Reading.h"
#include <string>
#include <memory>
#include <sstream>
#include "ITime.h"
#include "IReading.h"


#include <iostream>

namespace Sensor {

	class Reading : public IReading
	{
	private:
		const int sensorId;
		std::unique_ptr<ITime> time;
		std::string type;
		const double value;
	public:
		Reading(int sensorId, std::unique_ptr<ITime>& time, std::string type, double value) :
		  sensorId(sensorId), type(type), value(value)
		{
			this->time = std::move(time);
		}

		virtual std::unique_ptr<IReading> copy() const {
			return std::unique_ptr<IReading>(
				new Reading(getSensorId(), getTime()->copy(), getType(), getValue()));
		}

		virtual const int getSensorId() const {
			return sensorId;
		}

		virtual const ITime* getTime() const {
			return time.get();
		}

		virtual const std::string getType() const {
			return type;
		}

		virtual const double getValue() const {
			return value;
		}

		virtual const std::string getRepresentation() const {
			std::ostringstream representation;
			representation << "Reading[sensorId=" << sensorId << " time=" << time->getRepresentation()
				<< " type=" << type << " value=" << value << "]";
			return representation.str();
		}
	};

}
